package com.example.db;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import com.example.R;

/**
 * User: wlai
 * Date: 2/18/14
 * Time: 1:55 PM
 */
public class ListRecordsActivity extends ListActivity {
    DbHelper helper = null;
    Cursor model = null;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.list_records);
        helper = new DbHelper(this);
        model = helper.listRecord();


    }

    private void initList() {
        if (model != null) {
            stopManagingCursor(model);
            model.close();
        }

        model = helper.listRecord();
        startManagingCursor(model);
//        adapter = new RecordAdapter(model);
//        setListAdapter(adapter);
        setListAdapter(new SimpleCursorAdapter(ListRecordsActivity.this, android.R.layout.activity_list_item, model,
                new String[]{RecordEntry.COLUMN_NAME_RECORD_MONEY}, new int[]{android.R.id.text1}));
    }
}
